package com.david.IfaceAutoTest.controller;

import com.david.IfaceAutoTest.entity.Girl;
import com.david.IfaceAutoTest.service.GirlService;
import io.swagger.annotations.*;
import com.david.IfaceAutoTest.entity.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 控制层
 *
 * @author david
 * @since 2021-12-14
 */
@RestController
@Api(tags = "girl接口")
@RequestMapping("/IfaceAutoTest/girl")
public class GirlController {


    private final GirlService girlservice;

    @Autowired
    public GirlController(GirlService girlservice) {
        this.girlservice = girlservice;
    }

    @GetMapping("/list")
    @ApiOperation(value = "列表查询", notes = "list")
    public CommonResult<Object> list() {
        return CommonResult.success(girlservice.list());
    }

    @GetMapping("/get")
    @ApiOperation(value = "详情查询", notes = "get")
    public CommonResult<Object> get(Integer id) {
        return CommonResult.success(girlservice.getById(id));
    }

    @PostMapping("/save")
    @ApiOperation(value = "保存", notes = "save")
    public CommonResult<Object> save(Girl girl) {
        return CommonResult.success(girlservice.save(girl));
    }

    @DeleteMapping("/delete")
    @ApiOperation(value = "删除", notes = "delete")
    public CommonResult<Object> delete(Integer id) {
        girlservice.removeById(id);
        return CommonResult.success();
    }
}
